package com.codi.api.controller.organ;

/**
 * Created by wangzhenhao on 2017/9/11.
 */

import com.codi.base.domain.BaseResult;
import com.codi.base.log.annotation.Loggable;
import com.codi.bus.core.domain.OrgFileBucket;
import com.codi.bus.core.service.organ.OrgFileBucketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 文件桶管理
 */
@RestController
@RequestMapping("/organ/fileBucket")
public class OrganFileBucketController {
    @Autowired
    private OrgFileBucketService orgFileBucketService;

    @Loggable
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public BaseResult add(OrgFileBucket orgFileBucket) {
        return BaseResult.success(orgFileBucketService.add(orgFileBucket));
    }

    @Loggable
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public BaseResult update(OrgFileBucket orgFileBucket) {
        orgFileBucketService.update(orgFileBucket);

        return BaseResult.success();
    }


    @Loggable
    @RequestMapping(value = "/{bucketId}", method = RequestMethod.DELETE)
    public BaseResult delete(@PathVariable(name = "bucketId") Long bucketId) {
        orgFileBucketService.delete(bucketId);

        return BaseResult.success();
    }

    @Loggable
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public BaseResult queryFileBuckets() {

        return BaseResult.success(orgFileBucketService.query());
    }
}
